// ignore_for_file: file_names, slash_for_doc_comments, must_call_super, unnecessary_overrides, override_on_non_overriding_member, must_be_immutable, prefer_const_constructors

import 'package:flutter/material.dart';
import 'package:mybase/base/abstract/IFFR.dart';
import 'package:mybase/base/abstract/IFFRefresh.dart';
import 'package:mybase/base/abstract/IFFScaffold.dart';
import 'package:mybase/base/widget/page/FFListScaffold.dart';
import 'package:mybase/base/tool/extension/FFListExt.dart';

class TemplateListPage extends FFListScaffold {
  String? name;

  TemplateListPage({
    Key? key,
    this.name,
  }) : super(key: key);

  @override
  TemplateListPageState createState() => TemplateListPageState();
}

class TemplateListPageState extends FFListScaffoldState {
  /**固定写法 */
  @override
  IFFScaffold get iffScaffold => this;

  @override
  TemplateListPage get widget => super.widget as TemplateListPage;

  ///刷新控制
  @override
  IFFRefresh? get iffRefresh => refresh;
  late TemplateListPageStateRefresh refresh =
      TemplateListPageStateRefresh(state: this);

  @override
  FFPageSpacingParam? get ffPageSpacingParam =>
      FFPageSpacingParam(bottomSpacing: true);

  /**固定写法end */

  @override
  void ffInitState() {
    super.ffInitState();
  }

  @override
  Widget? ffNavi(BuildContext context) {
    // return AppNavi.createNavi(
    //   context,
    //   title: "Title",
    //   actions: [
    //     DueNaviAction(
    //         value: 'assets/images/detail/settings_24px.png',
    //         type: DueNaviActionType.img,
    //         onClick: () {}),
    //     DueNaviAction(
    //         type: DueNaviActionType.img,
    //         value: 'assets/images/home/road.png',
    //         onClick: () async {})
    //   ],
    // );
  }

  @override
  Widget ffItem(BuildContext context, int index) {
    return Container(
      height: 44,
      color: Colors.pink,
      margin: EdgeInsets.only(top: 2),
    );
  }
}

class TemplateListPageStateRefresh with MFFRefresh {
  TemplateListPageState state;

  TemplateListPageStateRefresh({required this.state});

  @override
  bool? ffCanRefreshHead() {
    return true;
  }

  @override
  bool? ffCanRefreshFoot() {
    return true;
  }

  @override
  ffRefresh(bool isHead) {
    ffRefreshResult(isHead, test, state);
  }

  Future<IFFR> test(IRefreshParam? iRefreshParam) async {
    return R(rStatus: RStatus.result);
  }
}
